﻿-------------DAT PHONG -----------------

--KHACH DAT PHONG
create proc sp_KhachDatPhong_Them
   @DANHXUNG nchar(5)
      ,@HOTEN nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20)
      ,@SODTDD nvarchar(20)
      ,@EMAIL nvarchar(100)
      ,@FAX nvarchar(20)
as
begin
	insert into KHACHDATPHONG(
	  DANHXUNG
      ,HOTEN
      ,DIACHI
      ,SODT
      ,SODTDD
      ,EMAIL
      ,FAX
	)values(
	
	  @DANHXUNG
      ,@HOTEN
      ,@DIACHI
      ,@SODT
      ,@SODTDD
      ,@EMAIL
      ,@FAX
      )
      select @@IDENTITY
end
go
create proc sp_KhachDatPhong_Xoa
@ID_KHACHDAT int
as
begin
	delete KHACHDATPHONG
	
      where @ID_KHACHDAT = ID_KHACHDAT
end
go
create proc sp_KhachDatPhong_Sua
   @DANHXUNG nchar(5)
      ,@HOTEN nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20)
      ,@SODTDD nvarchar(20)
      ,@EMAIL nvarchar(100)
      ,@FAX nvarchar(20)
      ,@ID_KHACHDAT int
as
begin
	update KHACHDATPHONG
	set
	  DANHXUNG=@DANHXUNG
      ,HOTEN=@HOTEN
      ,DIACHI=@DIACHI
      ,SODT=@SODT
      ,SODTDD=@SODTDD
      ,EMAIL=@EMAIL
      ,FAX=@FAX 
      where @ID_KHACHDAT = ID_KHACHDAT
end

--AITHANHTOAN
go
--AI THANH TOAN
create proc sp_AiThanhToan_Them
@MAAITT int
 ,@DIENGIAI nvarchar(100)
as
begin
	insert into AITHANHTOAN
	 (MAAITT
	  ,DIENGIAI)
	 values (@MAAITT
		  ,@DIENGIAI)
	select @@IDENTITY
end		  
go
create proc sp_AiThanhToan_Xoa
@MAAITT int
as
begin
	delete AITHANHTOAN
	 where @MAAITT = MAAITT
end
go
create proc sp_AiThanhToan_Sua
@MAAITT int
 ,@DIENGIAI nvarchar(100)
as
begin
	update AITHANHTOAN
	 set 
	 DIENGIAI=@DIENGIAI
	 where MAAITT = @MAAITT
end		  

--KIEU THANH TOAN
go
--KIEU THANH TOAN
create proc sp_KieuThanhToan_Them
@MATT nchar(10),
@DIENGIAI nvarchar(50)
as
begin
insert into KIEUTHANHTOAN
  (MATT
      ,DIENGIAI)
  values
  (@MATT
      ,@DIENGIAI)
  select @@IDENTITY
  end
go
create proc sp_KieuThanhToan_Sua  
@MATT nchar(10),
@DIENGIAI nvarchar(50)
as
begin
update KIEUTHANHTOAN
  set
	DIENGIAI = @DIENGIAI
  where MATT = @MATT
  end  
go
create proc sp_KieuThanhToan_Xoa  
@MATT nchar(10)
as
begin
delete KIEUTHANHTOAN
  where MATT = @MATT
  end
  
  

go
--PHAN LOAI THI TRUONG
create proc sp_PhanLoaiThiTruong_Them
	@MAPLTT int
      ,@DIENGIAI nvarchar(50)
      ,@CANHAN bit
      ,@DOAN bit
      ,@VANGLAI bit
      ,@MIENPHI bit
as
begin
  insert into PHANLOAITHITRUONG
	(	MAPLTT
      ,DIENGIAI
      ,CANHAN
      ,DOAN
      ,VANGLAI
      ,MIENPHI)
  values 
  (
		@MAPLTT
      ,@DIENGIAI
      ,@CANHAN
      ,@DOAN
      ,@VANGLAI
      ,@MIENPHI
  )
  select @@IDENTITY
  end
  
go
create proc sp_PhanLoaiThiTruong_Sua
	   @MAPLTT int
	   ,@DIENGIAI nvarchar(50)
      ,@CANHAN bit
      ,@DOAN bit
      ,@VANGLAI bit
      ,@MIENPHI bit
as
begin
  update PHANLOAITHITRUONG
  set
      DIENGIAI = @DIENGIAI
      ,CANHAN = @CANHAN
      ,DOAN = @DOAN
      ,VANGLAI = @VANGLAI
      ,MIENPHI=@MIENPHI
  where MAPLTT = @MAPLTT
  end
  
go
  create proc sp_PhanLoaiThiTruong_Xoa
	   @MAPLTT int
as
begin
  delete PHANLOAITHITRUONG
    where MAPLTT = @MAPLTT
  end
  
go
--TRANG THAI DAT PHONG
create proc sp_TrangThaiDatPhong_Them
@MATTDP int
	,@DIENGIAI nvarchar(100)
as
begin
	insert into TRANGTHAIDATPHONG
  (
	  MATTDP
	,DIENGIAI
  )
  values
  (
		@MATTDP
	,@DIENGIAI
  )
  select @@IDENTITY
end
go
create proc sp_TrangThaiDatPhong_Sua
@MATTDP int
	,@DIENGIAI nvarchar(100)
as
begin
	update TRANGTHAIDATPHONG
  set
	DIENGIAI=@DIENGIAI
  where MATTDP = @MATTDP
end
go
create proc sp_TrangThaiDatPhong_Xoa
@MATTDP int
as
begin
	delete TRANGTHAIDATPHONG
  where MATTDP = @MATTDP
end
go
--Nhan Vien
create proc sp_NhanVien_Them
	@MANV nchar(10)
      ,@HO nvarchar(50)
      ,@TEN nvarchar(10)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20)
      ,@EMAIL nvarchar(100)
      ,@MABP nchar(10)
      ,@MAKS int
as
begin
	insert into NHANVIEN
  (
	MANV
      ,HO
      ,TEN
      ,DIACHI
      ,SODT
      ,EMAIL
      ,MABP
      ,MAKS
  )
  values
  (
	@MANV
      ,@HO
      ,@TEN
      ,@DIACHI
      ,@SODT
      ,@EMAIL
      ,@MABP
      ,@MAKS
  )
  select @@IDENTITY
end
go
create proc sp_NhanVien_Xoa
	@MANV nchar(10)
as
begin
	delete NHANVIEN
     where MANV = @MANV
end
go
create proc sp_NhanVien_Sua
	@MANV nchar(10)
      ,@HO nvarchar(50)
      ,@TEN nvarchar(10)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20)
      ,@EMAIL nvarchar(100)
      ,@MABP nchar(10)
      ,@MAKS int
as
begin
	update NHANVIEN
  set
      HO=@HO
      ,TEN=@TEN
      ,DIACHI=@DIACHI
      ,SODT=@SODT
      ,EMAIL=@EMAIL
      ,MABP=@MABP
      ,MAKS=@MAKS
     where MANV = @MANV
end
go
--PHIEU DAT PHONG
create proc sp_PhieuDatPhong_Them
	@MABOOKING int
      ,@NGAYDAT datetime
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@GIUPHONGDEN time(7)
      ,@ID_KHACHDAT int
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTLIENHE nchar(20)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@TENDOAN nvarchar(200)
      ,@THEMGIUONG int
      ,@TREEM int
      ,@EMBE int
      ,@HOAHONG int
      ,@MATT nchar(10)
      ,@SOTHE nvarchar(30)
      ,@DATCOC int
      ,@MAAITT int
      ,@MAPLTT int
      ,@MANVXN nchar(10)
      ,@NGAYXN datetime
      ,@NGAYHETHAN datetime
      ,@MATTDP int
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
as
begin
	set dateformat 'dmy'
	insert into PHIEUDATPHONG
  (
		MABOOKING
      ,NGAYDAT
      ,NGAYDEN
      ,GIODEN
      ,NGAYDI
      ,GIODI
      ,GIUPHONGDEN
      ,ID_KHACHDAT
      ,HOTENLIENHE
      ,SODTLIENHE
      ,SODTDDLIENHE
      ,ID_CTYLH
      ,ID_CTY
      ,TENDOAN
      ,THEMGIUONG
      ,TREEM
      ,EMBE
      ,HOAHONG
      ,MATT
      ,SOTHE
      ,DATCOC
      ,MAAITT
      ,MAPLTT
      ,MANVXN
      ,NGAYXN
      ,NGAYHETHAN
      ,MATTDP
      ,MANV_UPDATE
      ,LASTUPDATE
  )
  values
  (
	@MABOOKING
      ,@NGAYDAT
      ,@NGAYDEN
      ,@GIODEN
      ,@NGAYDI
      ,@GIODI
      ,@GIUPHONGDEN
      ,@ID_KHACHDAT
      ,@HOTENLIENHE
      ,@SODTLIENHE
      ,@SODTDDLIENHE
      ,@ID_CTYLH
      ,@ID_CTY
      ,@TENDOAN
      ,@THEMGIUONG
      ,@TREEM
      ,@EMBE
      ,@HOAHONG
      ,@MATT
      ,@SOTHE
      ,@DATCOC
      ,@MAAITT
      ,@MAPLTT
      ,@MANVXN
      ,@NGAYXN
      ,@NGAYHETHAN
      ,@MATTDP
      ,@MANV_UPDATE
      ,@LASTUPDATE
  )
  select @@IDENTITY	
end
go
create proc sp_PhieuDatPhong_Sua
	@MABOOKING int
      ,@NGAYDAT datetime
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@GIUPHONGDEN time(7)
      ,@ID_KHACHDAT int
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTLIENHE nchar(20)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@TENDOAN nvarchar(200)
      ,@THEMGIUONG int
      ,@TREEM int
      ,@EMBE int
      ,@HOAHONG int
      ,@MATT nchar(10)
      ,@SOTHE nvarchar(30)
      ,@DATCOC int
      ,@MAAITT int
      ,@MAPLTT int
      ,@MANVXN nchar(10)
      ,@NGAYXN datetime
      ,@NGAYHETHAN datetime
      ,@MATTDP int
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
as
begin
	set dateformat 'dmy'
	update PHIEUDATPHONG
  set
	NGAYDAT=@NGAYDAT
      ,NGAYDEN =@NGAYDEN
      ,GIODEN=@GIODEN
      ,NGAYDI=@NGAYDI
      ,GIODI=@GIODI
      ,GIUPHONGDEN=@GIUPHONGDEN
      ,ID_KHACHDAT=@ID_KHACHDAT
      ,HOTENLIENHE=@HOTENLIENHE
      ,SODTLIENHE=@SODTLIENHE
      ,SODTDDLIENHE=@SODTDDLIENHE
      ,ID_CTYLH=@ID_CTYLH
      ,ID_CTY=@ID_CTY
      ,TENDOAN=@TENDOAN
      ,THEMGIUONG=@THEMGIUONG
      ,TREEM=@TREEM
      ,EMBE=@EMBE
      ,HOAHONG=@HOAHONG
      ,MATT=@MATT
      ,SOTHE=@SOTHE
      ,DATCOC=@DATCOC
      ,MAAITT=@MAAITT
      ,MAPLTT=@MAPLTT
      ,MANVXN=@MANVXN
      ,NGAYXN=@NGAYXN
      ,NGAYHETHAN=@NGAYHETHAN
      ,MATTDP=@MATTDP
      ,MANV_UPDATE=@MANV_UPDATE
      ,LASTUPDATE=@LASTUPDATE
  where MABOOKING = @MABOOKING
end
go
create proc sp_PhieuDatPhong_Xoa
	@MABOOKING int
as
begin
	delete PHIEUDATPHONG
  where MABOOKING = @MABOOKING
end
go
--CHI TIET PHIEU DAT PHONG
create proc sp_ChiTietPhieuDatPhong_Them
	@MABOOKING int
      ,@MAHANGPHONG nchar(20)
      ,@SOLUONG int 
      ,@DONGIA int
as
begin
	insert into CT_PDP
  (
	MABOOKING
      ,MAHANGPHONG
      ,SOLUONG
      ,DONGIA
  )
  values
  (
	@MABOOKING
      ,@MAHANGPHONG
      ,@SOLUONG
      ,@DONGIA
  )
  select @@IDENTITY
end
go
create proc sp_ChiTietPhieuDatPhong_Sua
	@MABOOKING int
      ,@MAHANGPHONG nchar(20)
      ,@SOLUONG int 
      ,@DONGIA int
as
begin
	update CT_PDP
  set
      SOLUONG=@SOLUONG
      ,DONGIA=@DONGIA
      where MABOOKING = @MABOOKING and MAHANGPHONG = @MAHANGPHONG
end
go
create proc sp_ChiTietPhieuDatPhong_Xoa
	@MABOOKING int
as
begin
	delete CT_PDP
	where MABOOKING = @MABOOKING and MAHANGPHONG = @MAHANGPHONG
end
go
--CÔNG TY
create proc sp_CongTy_Them
	@TENCTY nvarchar(100)
      ,@SODT nvarchar(20)
      ,@FAX nvarchar(20)
      ,@TENNGUOIDD nvarchar(100)
      ,@EMAIL nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@MAGG nchar(2)
      ,@MANGANHANG nchar(10)
      ,@SOTKNH nchar(20)
      ,@MASOTHUE nchar(20)
      ,@MANV nchar(10)
      ,@LASTUPDATE date
as
begin
	set dateformat 'dmy'
	insert into CONGTY
  (
      TENCTY
      ,SODT
      ,FAX
      ,TENNGUOIDD
      ,EMAIL
      ,DIACHI
      ,MAGG
      ,MANGANHANG
      ,SOTKNH
      ,MASOTHUE
      ,MANV
      ,LASTUPDATE
  )
  values
  (
      @TENCTY
      ,@SODT
      ,@FAX
      ,@TENNGUOIDD
      ,@EMAIL
      ,@DIACHI
      ,@MAGG
      ,@MANGANHANG
      ,@SOTKNH
      ,@MASOTHUE
      ,@MANV
      ,@LASTUPDATE
  )
  select @@IDENTITY
end
go
create proc sp_CongTy_Sua
	@ID_CTY int
	,@TENCTY nvarchar(100)
      ,@SODT nvarchar(20)
      ,@FAX nvarchar(20)
      ,@TENNGUOIDD nvarchar(100)
      ,@EMAIL nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@MAGG nchar(2)
      ,@MANGANHANG nchar(10)
      ,@SOTKNH nchar(20)
      ,@MASOTHUE nchar(20)
      ,@MANV nchar(10)
      ,@LASTUPDATE date
as
begin
	set dateformat 'dmy'
	update CONGTY
  set
      TENCTY=@TENCTY
      ,SODT=@SODT
      ,FAX=@FAX
      ,TENNGUOIDD=@TENNGUOIDD
      ,EMAIL=@EMAIL
      ,DIACHI=@DIACHI
      ,MAGG=@MAGG
      ,MANGANHANG=@MANGANHANG
      ,SOTKNH=@SOTKNH
      ,MASOTHUE=@MASOTHUE
      ,MANV=@MANV
      ,LASTUPDATE=@LASTUPDATE
  where ID_CTY=@ID_CTY
end
go
create proc sp_CongTy_Xoa
	@ID_CTY int
as
begin
	delete CONGTY
  where ID_CTY=@ID_CTY
end
go
--CÔNG TY LỮ HÀNH
create proc sp_CongTyLuHanh_Them
	@TENCTY nvarchar(100)
      ,@SODT nvarchar(20)
      ,@TENNGUOIDD nvarchar(100)
      ,@EMAIL nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@MANGANHANG nchar(10)
      ,@SOTKNH nchar(20)
      ,@MASOTHUE nchar(20)
      ,@MALH nchar(2)
      ,@MAGG nchar(2)
      ,@MANHOM int
      ,@MANV nchar(10)
      ,@LASTUPDATE date
as
begin
	set dateformat 'dmy'
	insert into CONGTY_LUHANH
  (
  TENCTY 
      ,SODT
      ,TENNGUOIDD
      ,EMAIL
      ,DIACHI
      ,MANGANHANG
      ,SOTKNH
      ,MASOTHUE
      ,MALH
      ,MAGG
      ,MANHOM
      ,MANV
      ,LASTUPDATE
  )
  values
  (
	@TENCTY
      ,@SODT
      ,@TENNGUOIDD
      ,@EMAIL
      ,@DIACHI
      ,@MANGANHANG
      ,@SOTKNH
      ,@MASOTHUE
      ,@MALH
      ,@MAGG
      ,@MANHOM
      ,@MANV
      ,@LASTUPDATE
  )
  select @@IDENTITY	
end
go
create proc sp_CongTyLuHanh_Sua
	@ID_CTYLH int
	,@TENCTY nvarchar(100)
      ,@SODT nvarchar(20)
      ,@TENNGUOIDD nvarchar(100)
      ,@EMAIL nvarchar(100)
      ,@DIACHI nvarchar(200)
      ,@MANGANHANG nchar(10)
      ,@SOTKNH nchar(20)
      ,@MASOTHUE nchar(20)
      ,@MALH nchar(2)
      ,@MAGG nchar(2)
      ,@MANHOM int
      ,@MANV nchar(10)
      ,@LASTUPDATE date
as
begin
	set dateformat 'dmy'
	update CONGTY_LUHANH
  set
  TENCTY =@TENCTY
      ,SODT=@SODT
      ,TENNGUOIDD=@TENNGUOIDD
      ,EMAIL=@EMAIL
      ,DIACHI=@DIACHI
      ,MANGANHANG=@MANGANHANG
      ,SOTKNH=@SOTKNH
      ,MASOTHUE=@MASOTHUE
      ,MALH=@MALH
      ,MAGG=@MAGG
      ,MANHOM=@MANHOM
      ,MANV=@MANV
      ,LASTUPDATE=@LASTUPDATE
  where ID_CTYLH = @ID_CTYLH
end
go
create proc sp_CongTyLuHanh_Xoa
	@ID_CTYLH int
	as
begin
	delete CONGTY_LUHANH
  where ID_CTYLH = @ID_CTYLH
end
go
--Loai_Kieu phong
create proc sp_Loai_KieuPhong_Them
	@mahangphong nchar(20)
	,@malp nchar(10)
	,@makp nchar(10)	
as
begin
	insert into LOAI_KIEUPHONG(MAHANGPHONG,MALP,MAKP)
	values (@mahangphong,@malp,@makp)
	select @@IDENTITY
end
go
create proc sp_Loai_KieuPhong_Sua
	@mahangphong nchar(20)
	,@malp nchar(10)
	,@makp nchar(10)	
as
begin
	update LOAI_KIEUPHONG
	set MALP=@malp,MAKP=@makp
	where MAHANGPHONG = @mahangphong
end
go
create proc sp_Loai_KieuPhong_Xoa
	@mahangphong nchar(20)
as
begin
	delete LOAI_KIEUPHONG
	where MAHANGPHONG = @mahangphong
end
go
--Giam Gia
create proc sp_GiamGia_Them
	@magg nchar(2)
	,@mucgiam int
as
begin
	insert into GIAMGIA(MAGG,MUCGIAM)
	values (@magg,@mucgiam)
	select @@IDENTITY	
end
go
create proc sp_GiamGia_Sua
	@magg nchar(2)
	,@mucgiam int
as
begin
	update GIAMGIA
	set MUCGIAM=@mucgiam
	where MAGG = @magg
end
go
create proc sp_GiamGia_Xoa
	@magg nchar(2)
as
begin
	delete GIAMGIA
	where MAGG = @magg
end
go
--LOẠI HẠNG LỮ HÀNH
create proc sp_LoaiHangLuHanh_Them
	@malh nchar(2)
	,@diengiai nvarchar(100)
as
begin
	insert into LOAIHANGLUHANH(MALH,DIENGIAI)
	values (@malh,@diengiai)
	select @@IDENTITY	
end
go
create proc sp_LoaiHangLuHanh_Sua
	@malh nchar(2)
	,@diengiai nvarchar(100)
as
begin
	update LOAIHANGLUHANH
	set DIENGIAI = @diengiai
	where MALH = @malh
end
go
create proc sp_LoaiHangLuHanh_Xoa
	@malh nchar(2)
as
begin
	delete LOAIHANGLUHANH
	where MALH = @malh
end
go
--NHÓM CÔNG TY
create proc sp_NhomCongTy_Them
	@manhom int
	,@diengiai nvarchar(100)
as
begin
	insert into NHOMCONGTY(MANHOM,DIENGIAI)
	values (@manhom,@diengiai)
	select @@IDENTITY	
end
go
create proc sp_NhomCongTy_Sua
	@manhom int
	,@diengiai nvarchar(100)
as
begin
	update NHOMCONGTY
	set DIENGIAI = @diengiai
	where MANHOM = @manhom
end
go
create proc sp_NhomCongTy_Xoa
	@manhom int
as
begin
	delete NHOMCONGTY
	where MANHOM = @manhom
end
go
--LOẠI PHÒNG
create proc sp_LoaiPhong_Them
	@malp nchar(10)
	,@loaiph nvarchar(50)
as
begin
	insert into LOAIPHONG(MALP,LOAIPH)
	values (@malp,@loaiph)
	select @@IDENTITY	
end
go
create proc sp_LoaiPhong_Sua
	@malp nchar(10)
	,@loaiph nvarchar(50)
as
begin
	update LOAIPHONG
	set LOAIPH = @loaiph
	where MALP = @malp
end
go
create proc sp_LoaiPhong_Xoa
	@malp nchar(10)
as
begin
	delete LOAIPHONG
	where MALP = @malp
end
go
--KIỂU PHÒNG
create proc sp_KieuPhong_Them
	@makp nchar(10)
	,@diengiai nvarchar(100)
as
begin
	insert into KIEUPHONG(MAKP,DIENGIAI)
	values (@makp,@diengiai)
	select @@IDENTITY	
end
go
create proc sp_KieuPhong_Sua
	@makp nchar(10)
	,@diengiai nvarchar(100)
as
begin
	update KIEUPHONG
	set DIENGIAI = @diengiai
	where MAKP = @makp
end
go
create proc sp_LoaiPhong_Xoa
	@makp nchar(10)
as
begin
	delete KIEUPHONG
	where MAKP = @makp
end
go

--------------------------PHÒNG--------------------
--PHÒNG
create proc sp_Phong_Them
	@maph nchar(10)
	,@magia nchar(30)
	,@mattp int
	,@makv nchar(4)
as
begin
	insert into PHONG(MAPH,MAGIA,MATTP,MAKV)
	values (@maph,@magia,@mattp,@makv)
	select @@IDENTITY	
end
go
create proc sp_Phong_Sua
	@maph nchar(10)
	,@magia nchar(30)
	,@mattp int
	,@makv nchar(4)
as
begin
	update PHONG
	set MAGIA=@magia,MATTP=@mattp,MAKV=@makv
	where MAPH = @maph
end
go
create proc sp_Phong_Xoa
	@maph nchar(10)
as
begin
	delete PHONG
	where MAPH = @maph
end
go
--GIÁ PHÒNG
create proc sp_GiaPhong_Them
	@MAGIA nchar(30)
      ,@MAHANGPHONG nchar(20)
      ,@DIENGIAI nvarchar(100)
      ,@TUNGAY date
      ,@DENNGAY date
      ,@GIA1KHACH int
      ,@GIA2KHACH int
      ,@GIA3KHACH int
      ,@GIA4KHACH int
      ,@GIATHEMNGLON int
      ,@GIATHEMTREEM int
as
begin
	insert into GIAPHONG
  (
	MAGIA
      ,MAHANGPHONG
      ,DIENGIAI
      ,TUNGAY
      ,DENNGAY
      ,GIA1KHACH
      ,GIA2KHACH
      ,GIA3KHACH
      ,GIA4KHACH
      ,GIATHEMNGLON
      ,GIATHEMTREEM
  )
  values
  (
	@MAGIA
      ,@MAHANGPHONG
      ,@DIENGIAI
      ,@TUNGAY
      ,@DENNGAY
      ,@GIA1KHACH
      ,@GIA2KHACH
      ,@GIA3KHACH
      ,@GIA4KHACH
      ,@GIATHEMNGLON
      ,@GIATHEMTREEM
  )
  select @@IDENTITY
end
go
create proc sp_GiaPhong_Sua
	@MAGIA nchar(30)
      ,@MAHANGPHONG nchar(20)
      ,@DIENGIAI nvarchar(100)
      ,@TUNGAY date
      ,@DENNGAY date
      ,@GIA1KHACH int
      ,@GIA2KHACH int
      ,@GIA3KHACH int
      ,@GIA4KHACH int
      ,@GIATHEMNGLON int
      ,@GIATHEMTREEM int
as
begin
	set dateformat 'dmy'
	update GIAPHONG
  set
	MAHANGPHONG =@MAHANGPHONG
      ,DIENGIAI=@DIENGIAI
      ,TUNGAY=@TUNGAY
      ,DENNGAY=@DENNGAY
      ,GIA1KHACH=@GIA1KHACH
      ,GIA2KHACH=@GIA2KHACH
      ,GIA3KHACH=@GIA3KHACH
      ,GIA4KHACH=@GIA4KHACH
      ,GIATHEMNGLON=@GIATHEMNGLON
      ,GIATHEMTREEM=@GIATHEMTREEM
   where MAGIA = @MAGIA
end
go
create proc sp_GiaPhong_Xoa
	@MAGIA nchar(30)
as
begin
	delete GIAPHONG
   where MAGIA = @MAGIA
end
go
--CT_PHONG_THIETBI
create proc sp_CTPhongThietBi_Them
	@maph nchar(10)
	,@matb nchar(10)
	,@soluong int
	,@dongia int
as
begin
	insert into CT_PHONG_THIETBI(MAPH,MATB,SOLUONG,DONGIA)
	values (@maph,@matb,@soluong,@dongia)
	select @@IDENTITY	
end
go
create proc sp_CTPhongThietBi_Sua
	@maph nchar(10)
	,@matb nchar(10)
	,@soluong int
	,@dongia int
as
begin
	update CT_PHONG_THIETBI
	set SOLUONG=@soluong,DONGIA=@dongia
	where MAPH= @maph and MATB=@matb
end
go
create proc sp_CTPhongThietBi_Xoa
	@maph nchar(10)
	,@matb nchar(10)
as
begin
	delete CT_PHONG_THIETBI
	where MAPH= @maph and MATB = @matb
end
go
--TRANG THIẾT BỊ
create proc sp_TrangThietBi_Them
	@matb nchar(10)
	,@tentb nvarchar(100)
	,@dongia int
as
begin
	insert into TRANGTHIETBI(MATB,TENTB,DONGIA)
	values (@matb,@tentb,@dongia)
	select @@IDENTITY
end
go
create proc sp_TrangThietBi_Sua
	@matb nchar(10)
	,@tentb nvarchar(100)
	,@dongia int
as
begin
	update TRANGTHIETBI
	set TENTB = @tentb,DONGIA=@dongia
	where MATB = @matb
end
go
create proc sp_TrangThietBi_Xoa
	@matb nchar(10)
	as
begin
	delete TRANGTHIETBI
	where MATB = @matb
end
go
--KHU VỰC
create proc sp_KhuVuc_Them
	@makv nchar(4)
	,@diengiai nvarchar(30)
	,@maks int
as
begin
	insert into KHUVUC(MAKV,DIENGIAI,MAKS)
	values (@makv,@diengiai,@maks)
	select @@IDENTITY
end
go
create proc sp_KhuVuc_Sua
	@makv nchar(4)
	,@diengiai nvarchar(30)
	,@maks int
as
begin
	update KHUVUC
	set DIENGIAI=@diengiai,MAKS=@maks
	where MAKV=@makv
end
go
create proc sp_KhuVuc_Xoa
	@makv nchar(4)
as
begin
	delete KHUVUC
	where MAKV=@makv
end
go
--GIÁ PHÒNG - GIẢM GIÁ
create proc sp_GiaPhong_GiamGia_Them
	@magia nchar(30)
	,@malh nchar(2)
	,@magg nchar(2)
as
begin
	insert into GIAPHONG_GIAMGIA(MAGIA,MALH,MAGG)
	values (@magia,@malh,@magg)
	select @@IDENTITY
end
go
create proc sp_GiaPhong_GiamGia_Sua
	@magia nchar(30)
	,@malh nchar(2)
	,@magg nchar(2)
as
begin
	update GIAPHONG_GIAMGIA
	set MAGG=@magg
	where MAGIA = @magia and MALH = @malh
end
go
create proc sp_GiaPhong_GiamGia_Xoa
	@magia nchar(30)
	,@malh nchar(2)
as
begin
	delete GIAPHONG_GIAMGIA
	where MAGIA = @magia and MALH = @malh
end
go

-----------------------------------NHÂN VIÊN--------------------
--BỘ PHẬN
create proc sp_BoPhan_Them
	@mabp nchar(10)
	,@tenbp nvarchar(50)
	,@manvql nchar(10)
as
begin
	insert into BOPHAN(MABP,TENBP,MANVQL)
	values (@mabp,@tenbp,@manvql)
	select @@IDENTITY
end
go
create proc sp_BoPhan_Sua
	@mabp nchar(10)
	,@tenbp nvarchar(50)
	,@manvql nchar(10)
as
begin
	update BOPHAN
	set TENBP = @tenbp,MANVQL=@manvql
	where MABP=@mabp
end
go
create proc sp_BoPhan_Xoa
	@mabp nchar(10)
as
begin
	delete BOPHAN
	where MABP=@mabp
end
go
--KHÁCH SẠN
create proc sp_KhachSan_Them
	@MAKS int
      ,@TENKS nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nchar(10)
as
begin
	insert into KHACHSAN
  (
	MAKS
      ,TENKS
      ,SODT
      ,DIACHI
      ,MANVQLY
  )
  values
  (
	@MAKS
      ,@TENKS
      ,@SODT
      ,@DIACHI
      ,@MANVQLY
  )
  select @@IDENTITY
end
go
create proc sp_KhachSan_Sua
	@MAKS int
      ,@TENKS nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nchar(10)
as
begin
	update KHACHSAN
  set
      TENKS=@TENKS
      ,SODT=@SODT
      ,DIACHI=@DIACHI
      ,MANVQLY=@MANVQLY
  where MAKS = @MAKS
end
go
create proc sp_KhachSan_Xoa
	@MAKS int
as
begin
	delete KHACHSAN
  where MAKS = @MAKS
end
go
--------- ĐẶT TIỆC -----------------

-- DỊCH VỤ TIỆC

Create proc sp_DichVu_Tiec_Them
	@DienGiai nvarchar(100),
	@DonGia int
	
as
begin
	insert into DICHVU_TIEC(DIENGIAI,DONGIA)values(@DienGiai,@DonGia)
	Select @@IDENTITY
end

go

Create proc sp_DichVu_Tiec_Sua
	@MaDV int,
	@DienGiai nvarchar(100),
	@DonGia int
	
as
begin
	update DICHVU_TIEC
	set DIENGIAI=@DienGiai,DONGIA=@DonGia
	where MADV=@MaDV
end


go

Create proc sp_DichVu_Tiec_Xoa
	@MaDV int
as
begin
	Delete DICHVU_TIEC
	where MADV=@MaDV
end

go


---------------------THỰC PHẨM---------------------------

create proc sp_ThucPham_Them
   @MATP int
  ,@TENTP nvarchar
  ,@MANHOM int
  ,@MATLTP nchar
  ,@KEOKHO bit
  ,@DVT nvarchar(20)
  ,@GIACHUAN int
  ,@GIABEP int
  ,@GIAVON int
  ,@GUYENLIEU int
as
begin
	insert into THUCPHAM
	(	
   MATP 
  ,TENTP 
  ,MANHOM 
  ,MATLTP
  ,KEOKHO
  ,DVT 
  ,GIACHUAN
  ,GIABEP
  ,GIAVON
  ,NGUYENLIEU
  
  )
	values(
	 @MATP 
  ,@TENTP 
  ,@MANHOM 
  ,@MATLTP
  ,@KEOKHO
  ,@DVT 
  ,@GIACHUAN
  ,@GIABEP
  ,@GIAVON
  ,@GUYENLIEU
  )
end

go

create proc sp_ThucPham_Sua
   @MATP int
  ,@TENTP nvarchar
  ,@MANHOM int
  ,@MATLTP nchar
  ,@KEOKHO bit
  ,@DVT nvarchar(20)
  ,@GIACHUAN int
  ,@GIABEP int
  ,@GIAVON int
  ,@NGUYENLIEU int
as
begin
	update THUCPHAM
	set 
  TENTP =@TENTP
  ,MANHOM =@MANHOM
  ,MATLTP=@MATLTP
  ,KEOKHO=@KEOKHO
  ,DVT =@DVT
  ,GIACHUAN=@GIACHUAN
  ,GIABEP=@GIABEP
  ,GIAVON=@GIAVON
  ,NGUYENLIEU=@NGUYENLIEU
   where MATP=@MATP
end

go

create proc sp_ThucPham_Xoa
   @MATP int
as
begin
	update THUCPHAM
	where MATP=@MATP
end

go

--------------- MENU -----------------
Create proc sp_Menu_Them
@DienGiai nvarchar(100)
,@Gia int
,@PhiPhucVu int
as
begin
	insert into MENU(
		DIENGIAI,
		GIA,
		PHIPHUCVU
	)values(
		@DienGiai,
		@Gia,
		@PhiPhucVu
	)
	select @@IDENTITY
end

go

Create proc sp_Menu_Sua
	@DienGiai nvarchar(100)
	,@Gia int
	,@PhiPhucVu int
	,@ID_MENU int
as
begin
	update MENU
	set
		DIENGIAI=@DienGiai
		,GIA=@Gia
		,PHIPHUCVU=@PhiPhucVu
	where
	ID_MENU=@ID_MENU
end

go

Create proc sp_Menu_Xoa
	@ID_Menu int
as
begin
	Delete MENU
	where ID_MENU=@ID_Menu
end


------------HỢP ĐỒNG ĐẶT TIỆC_MENU--------------------------
go

--------------HỢP ĐỒNG ĐẶC TIỆC_MENU-------------------------------
Create proc sp_HopDongDacTiec_Menu_Them
	@SOHD nchar(20)
      ,@ID_MENU int
      ,@SOBAN int
      ,@SOBANDATTHEM int
      ,@DONGIA int
as
begin
	insert into HOPDONGDATTIEC_MENU(
		SOHD
      ,ID_MENU
      ,SOBAN
      ,SOBANDATTHEM
      ,DONGIA
	)
	values(
		@SOHD
      ,@ID_MENU
      ,@SOBAN
      ,@SOBANDATTHEM
      ,@DONGIA
	)
end

go

Create proc sp_HopDongDacTiec_Menu_Sua
	@SOHD nchar(20)
      ,@ID_MENU int
      ,@SOBAN int
      ,@SOBANDATTHEM int
      ,@DONGIA int
as
begin
	update HOPDONGDATTIEC_MENU
	set
		SOBAN=@SOBAN
		,SOBANDATTHEM=@SOBANDATTHEM
		,DONGIA=@DONGIA
	where  
		SOHD=@SOHD and ID_MENU=@ID_MENU
end

go

Create proc sp_HopDongDacTiec_Menu_Xoa
		@SOHD nchar(20)
		,@ID_MENU int
as
begin
	Delete HOPDONGDATTIEC_MENU
	where SOHD=@SOHD and ID_MENU=@ID_MENU
end

-----------------------HỢP ĐỒNG ĐẶT TIỆT -----------------------------------

go
---------------HỢP ĐỒNG ĐẶT TIỆC---------------------------------
Create proc sp_HopDongDatTiec_Them
	   @SOHD nchar(20) 
      ,@MALT nchar(5)
      ,@MANH int
      ,@SOBAN int
      ,@SOBANDUBI int
      ,@SOBANDATTHEM int
      ,@SOKHACH int 
      ,@SOCMND int
      ,@HOTENKH int
      ,@SODTLL nchar(20)
      ,@DIACHI int
      ,@NGAYGIODAT int
      ,@NGAYGIOTOCHUC int
      ,@NGAYHETHAN int
      ,@ID_TTDT int
      ,@MATT int
      ,@GHICHU int
      ,@MANV int
      ,@LASTUPDATE int
as

begin

insert into HOPDONGDATTIEC(
	   SOHD
      ,MALT
      ,MANH
      ,SOBAN
      ,SOBANDUBI
      ,SOBANDATTHEM
      ,SOKHACH
      ,SOCMND
      ,HOTENKH
      ,SODTLL
      ,DIACHI
      ,NGAYGIODAT
      ,NGAYGIOTOCHUC
      ,NGAYHETHAN
      ,ID_TTDT
      ,MATT
      ,GHICHU
      ,MANV
      ,LASTUPDATE
)values(
	   @SOHD
	  ,@MALT
	  ,@MANH
	  ,@SOBAN
	  ,@SOBANDUBI
	  ,@SOBANDATTHEM
	  ,@SOKHACH
	  ,@SOCMND
	  ,@HOTENKH
	  ,@SODTLL
	  ,@DIACHI
	  ,@NGAYGIODAT
	  ,@NGAYGIOTOCHUC
	  ,@NGAYHETHAN
	  ,@ID_TTDT
	  ,@MATT
	  ,@GHICHU
	  ,@MANV
	  ,@LASTUPDATE
)
end

go

Create proc sp_HopDongDatTiec_Sua
	   @SOHD nchar(20) 
      ,@MALT nchar(5)
      ,@MANH int
      ,@SOBAN int
      ,@SOBANDUBI int
      ,@SOBANDATTHEM int
      ,@SOKHACH int 
      ,@SOCMND int
      ,@HOTENKH int
      ,@SODTLL nchar(20)
      ,@DIACHI int
      ,@NGAYGIODAT int
      ,@NGAYGIOTOCHUC int
      ,@NGAYHETHAN int
      ,@ID_TTDT int
      ,@MATT int
      ,@GHICHU int
      ,@MANV int
      ,@LASTUPDATE int
as

begin

update HOPDONGDATTIEC
	set
	   MALT=@MALT
      ,MANH=@MANH
      ,SOBAN=@SOBAN
      ,SOBANDUBI=@SOBANDUBI
      ,SOBANDATTHEM=@SOBANDATTHEM
      ,SOKHACH=@SOKHACH
      ,SOCMND=@SOCMND
      ,HOTENKH=@HOTENKH
      ,SODTLL=@SODTLL
      ,DIACHI=@DIACHI
      ,NGAYGIODAT=@NGAYGIODAT
      ,NGAYGIOTOCHUC=@NGAYGIOTOCHUC
      ,NGAYHETHAN=@NGAYHETHAN
      ,ID_TTDT=@ID_TTDT
      ,MATT=@MATT
      ,GHICHU=@GHICHU
      ,MANV=@MANV
      ,LASTUPDATE=@LASTUPDATE
	where SOHD=@SOHD
      
end


go

Create proc sp_HopDongDatTiec_Xoa
	   @SOHD nchar(20) 
as
begin

	delete HOPDONGDATTIEC
	where SOHD=@SOHD     
end


GO
--------------- SẢN PHẨM ĐẶT TIỆC----------------------

Create proc sp_SanPham_DatTiec_Them
      @DIENGIAI nvarchar(100)
      ,@MALOAISP nchar(2)
      ,@DVT nvarchar(10)
      ,@DONGIA int
      ,@GIAMGIA int
      ,@GHICHU nvarchar(500)
      ,@MANV nchar(10)
      ,@LASTUPDATE datetime
as
begin
	set dateformat 'dmy'
	insert into SANPHAM_DATTIEC(
	 DIENGIAI
      ,MALOAISP
      ,DVT
      ,DONGIA
      ,GIAMGIA
      ,GHICHU
      ,MANV
      ,LASTUPDATE
      )
	values(
	  @DIENGIAI
      ,@MALOAISP
      ,@DVT
      ,@DONGIA
      ,@GIAMGIA
      ,@GHICHU
      ,@MANV
      ,@LASTUPDATE
	)
end

go

Create proc sp_SanPham_DatTiec_Sua
      @DIENGIAI nvarchar(100)
      ,@MALOAISP nchar(2)
      ,@DVT nvarchar(10)
      ,@DONGIA int
      ,@GIAMGIA int
      ,@GHICHU nvarchar(500)
      ,@MANV nchar(10)
      ,@LASTUPDATE datetime
      ,@ID_SP int
as
begin
	set dateformat 'dmy'
	update SANPHAM_DATTIEC
	set
	   DIENGIAI=@DIENGIAI
      ,MALOAISP=@MALOAISP
      ,DVT=@DVT
      ,DONGIA=@DONGIA
      ,GIAMGIA=@GIAMGIA
      ,GHICHU=@GHICHU
      ,MANV=@MANV
      ,LASTUPDATE=@LASTUPDATE
     where ID_SP=@ID_SP
end

go

Create proc sp_SanPham_DatTiec_Xoa
      @ID_SP int
as
begin
	delete SANPHAM_DATTIEC
    where ID_SP=@ID_SP
end

go
---------------------LOẠI TIỆC------------------------

Create proc sp_LoaiTiec_Them
	@MaLT nchar(5)
	,@DienGiai nchar(50)
as
begin
	insert into LOAITIEC(MALT,DIENGIAI)values(@MaLT,@DienGiai)
end

go

Create proc sp_LoaiTiec_Sua
	 @MaLT nchar(5)
	,@DienGiai nchar(50)
as
begin
	update LOAITIEC
	set 
	DIENGIAI=@DienGiai
	where MALT=@MaLT
end


go

---?
Create proc sp_LoaiTiec_Xoa
	 @MaLT nchar(5)
as
begin
	delete LOAITIEC
	where MALT=@MaLT
end

go


---------------NHÀ HÀNG--------------------
Create proc sp_NhaHang_Them
	   @MANH int
      ,@TENNH nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nchar(10)
      ,@MANVQLY nchar(10)
      ,@SOBAN int
      ,@SOBANDATMIN int
      ,@PHUTHU int
      ,@DATCOC1 int
      ,@DATCOC2 int
      ,@MAKS int
as
begin
	insert into NHAHANG(
		MANH
      ,TENNH
      ,SODT
      ,DIACHI
      ,MANVQLY
      ,SOBAN
      ,SOBANDATMIN
      ,PHUTHU
      ,DATCOC1
      ,DATCOC2
      ,MAKS
      )values(
	  @MANH
      ,@TENNH
      ,@SODT
      ,@DIACHI
      ,@MANVQLY
      ,@SOBAN
      ,@SOBANDATMIN
      ,@PHUTHU
      ,@DATCOC1
      ,@DATCOC2
      ,@MAKS
	)
	
end

go

Create proc sp_NhaHang_Sua
	   @MANH int
      ,@TENNH nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nchar(10)
      ,@MANVQLY nchar(10)
      ,@SOBAN int
      ,@SOBANDATMIN int
      ,@PHUTHU int
      ,@DATCOC1 int
      ,@DATCOC2 int
      ,@MAKS int
as
begin
	   update NHAHANG
	   set
		TENNH=@TENNH
		  ,SODT=@SODT
		  ,DIACHI=@DIACHI
		  ,MANVQLY=@MANVQLY
		  ,SOBAN=@SOBAN
		  ,SOBANDATMIN=@SOBANDATMIN
		  ,PHUTHU=@PHUTHU
		  ,DATCOC1=@DATCOC1
		  ,DATCOC2=@DATCOC2
		  ,MAKS=@MAKS
		where MANH=@MANH
end

go

Create proc sp_NhaHang_Xoa
	   @MANH int
as
begin
	   delete NHAHANG
	   where MANH=@MANH
end

go


------------------- KIỂU THANH TOÁN-----------------------

Create proc sp_KieuThanhToan_Them
@MaTT nchar(10)
,@DienGiai nvarchar(50)
as
begin
	insert into KIEUTHANHTOAN(MATT,DIENGIAI)values(@MaTT,@DienGiai)
end

go

Create proc sp_KieuThanhToan_Sua
@MaTT nchar(10)
,@DienGiai nvarchar(50)
as
begin
	update KIEUTHANHTOAN 
	set DIENGIAI=@DienGiai
	Where MATT=@MaTT
end

go

Create proc sp_KieuThanhToan_Xoa
@MaTT nchar(10)
as
begin
	delete KIEUTHANHTOAN
	Where MATT=@MaTT
end

go

------------------HDDT_TRẠNG THÁI--------------------------------

Create proc sp_HDDT_TrangThai_Them
	@ID_TTDT int
	,@DienGiai nvarchar(30)
as
begin
	insert into HDDT_TRANGTHAI(ID_TTDT,DIENGIAI)values(@ID_TTDT,@DienGiai)
end

go

Create proc sp_HDDT_TrangThai_Sua
	@ID_TTDT int
	,@DienGiai nvarchar(30)
as
begin
	update HDDT_TRANGTHAI
	set DIENGIAI=@DienGiai
	where ID_TTDT=@ID_TTDT
end

go

Create proc sp_HDDT_TrangThai_Xoa
	@ID_TTDT int
as
begin
	delete HDDT_TRANGTHAI
	where ID_TTDT=@ID_TTDT
end

go

------------HỢP ĐỒNG ĐẶT TIỆC - ĐẶT CỘC---------------------------------

Create proc sp_HopDongDatTiec_DatCocThem
	   @SOHD nchar(20)
      ,@NGAY datetime
      ,@HOTEN_KH nvarchar(100)
      ,@SODT nvarchar(20)
      ,@SOTIEN int
      ,@MANVNHAN nchar(20)
  
as
begin
	set dateformat 'dmy'
	insert into HOPDONGDATTIEC_DATCOC(
	  SOHD
      ,NGAY
      ,HOTEN_KH
      ,SODT
      ,SOTIEN
      ,MANVNHAN
	)values(
	   @SOHD
      ,@NGAY
      ,@HOTEN_KH
      ,@SODT
      ,@SOTIEN
      ,@MANVNHAN
	)
end

go
Create proc sp_HopDongDatTiec_DatCocSua
	   @SOHD nchar(20)
      ,@NGAY datetime
      ,@HOTEN_KH nvarchar(100)
      ,@SODT nvarchar(20)
      ,@SOTIEN int
      ,@MANVNHAN nchar(20)
  
as
begin
	set dateformat 'dmy'
	update HOPDONGDATTIEC_DATCOC
	set
       HOTEN_KH=@HOTEN_KH
      ,SODT=@SODT
      ,SOTIEN=@SOTIEN
      ,MANVNHAN=@MANVNHAN
	where  SOHD=@SOHD and  NGAY=@NGAY
end

go
Create proc sp_HopDongDatTiec_DatCocXoa
	   @SOHD nchar(20)
      ,@NGAY datetime
as
begin
	set dateformat 'dmy'
	Delete HOPDONGDATTIEC_DATCOC
	where  SOHD=@SOHD and  NGAY=@NGAY
end

go
-------------HỢP ĐỒNG ĐẶT TIỆC CHI TIẾT-----------------------------

Create proc sp_HopDongDatTiec_ChiTiet_Them
	@SOHD nchar(20)
      ,@ID_SP int
      ,@MAKIEUSP nchar(2)
      ,@SOLUONG int
      ,@DONGIA int 
      ,@GIAMGIA int
      ,@GHICHU int
as
begin
	insert into HOPDONGDATTIEC_CT(
	SOHD
      ,ID_SP
      ,MAKIEUSP
      ,SOLUONG
      ,DONGIA
      ,GIAMGIA
      ,GHICHU
	)values(
	@SOHD
      ,@ID_SP
      ,@MAKIEUSP
      ,@SOLUONG
      ,@DONGIA
      ,@GIAMGIA
      ,@GHICHU
	)
end

go

Create proc sp_HopDongDatTiec_ChiTiet_Sua
	@SOHD nchar(20)
      ,@ID_SP int
      ,@MAKIEUSP nchar(2)
      ,@SOLUONG int
      ,@DONGIA int 
      ,@GIAMGIA int
      ,@GHICHU int
as
begin
	update HOPDONGDATTIEC_CT
	set
      MAKIEUSP=@MAKIEUSP
      ,SOLUONG=@SOLUONG
      ,DONGIA=@DONGIA
      ,GIAMGIA=@GIAMGIA
      ,GHICHU=@GHICHU
	where SOHD=@SOHD  and ID_SP=@ID_SP
end

go

Create proc sp_HopDongDatTiec_ChiTiet_Xoa
	@SOHD nchar(20)
      ,@ID_SP int
as
begin
	delete HOPDONGDATTIEC_CT
	where SOHD=@SOHD  and ID_SP=@ID_SP
end

go

----------------HỢP ĐỒNG ĐẶT TIỆT - DỊCH VỤ-------------------

Create proc sp_HopDongDatTiec_DichVu_Them
	@SoHD nchar(20)
	,@MaDV int
	,@SoLG int
	,@DonGia nchar(10)
as
begin
	insert into HOPDONGDATTIEC_DICHVU(
	SoHD
	,MaDV
	,SoLG
	,DonGia
	)
	values(	
	@SoHD
	,@MaDV
	,@SoLG
	,@DonGia
	)
end

go

Create proc sp_HopDongDatTiec_DichVu_Sua
	@SoHD nchar(20)
	,@MaDV int
	,@SoLG int
	,@DonGia nchar(10)
as
begin
	update HOPDONGDATTIEC_DICHVU
	set
	SoLG=@SoLG
	,DonGia=@DonGia
	where
	SoHD=@SoHD
	and MaDV=@MaDV	
end

go

Create proc sp_HopDongDatTiec_DichVu_Xoa
	@SoHD nchar(20)
	,@MaDV int
as
begin
	delete HOPDONGDATTIEC_DICHVU
	where
	SoHD=@SoHD
	and MaDV=@MaDV	
end

go
------------------ho
Create proc sp_HopDongDatTiec_CT_Kieu_Them
	   @MAKIEUSP nchar(2)
      ,@DIENGIAI nvarchar(100)
as
begin
	insert into HOPDONGDATTIEC_CT_KIEU(MAKIEUSP,DIENGIAI)values(@MAKIEUSP,@DIENGIAI)
end
go
Create proc sp_HopDongDatTiec_CT_Kieu_Sua
	   @MAKIEUSP nchar(2)
      ,@DIENGIAI nvarchar(100)
as
begin
	update HOPDONGDATTIEC_CT_KIEU
	set DIENGIAI= @DIENGIAI
	where MAKIEUSP=@MAKIEUSP
end
go
Create proc sp_HopDongDatTiec_CT_Kieu_Xoa
	   @MAKIEUSP nchar(2)
as
begin
	delete HOPDONGDATTIEC_CT_KIEU
	where MAKIEUSP=@MAKIEUSP
end
go

-----------------Sản phẩm - đặt tiệc - loại--------------------

Create proc sp_SanPham_DatTiec_Loai_Them
	@MaLoaiSP nchar(2)
	,@DienGiai nvarchar(100)

as
begin
	insert into SANPHAM_DATTIEC_LOAI(MaLoaiSP
	,DienGiai)
	values(@MaLoaiSP
	,@DienGiai)
end

go

Create proc sp_SanPham_DatTiec_Loai_Sua
	@MaLoaiSP nchar(2)
	,@DienGiai nvarchar(100)

as
begin
	update SANPHAM_DATTIEC_LOAI
	set DienGiai=@DienGiai
	where MaLoaiSP=@MaLoaiSP
end

go

Create proc sp_SanPham_DatTiec_Loai_Xoa
	@MaLoaiSP nchar(2)
as
begin
	delete SANPHAM_DATTIEC_LOAI
	where MaLoaiSP=@MaLoaiSP
end

go

---------------Khuyến mãi - ct- tiệc

create proc sp_KhuyenMai_CT_Tiec_Them
	@ID_SP int
      ,@MADV int
      ,@SOLG int 
      ,@DONGIA nchar(10)
 as
 begin
 
 insert into KHUYENMAI_CT_TIEC(ID_SP
      ,MADV
      ,SOLG 
      ,DONGIA)
      values(  
      @ID_SP
      ,@MADV
      ,@SOLG 
      ,@DONGIA
      )
end

go

create proc sp_KhuyenMai_CT_Tiec_Sua
	@ID_SP int
      ,@MADV int
      ,@SOLG int 
      ,@DONGIA nchar(10)
as
begin
 
	update KHUYENMAI_CT_TIEC
	set 
      SOLG =@SOLG
      ,DONGIA=@DONGIA
	Where ID_SP=@ID_SP
      and MADV=@MADV
end

go

create proc sp_KhuyenMai_CT_Tiec_Xoa
	@ID_SP int
      ,@MADV int
      ,@SOLG int 
      ,@DONGIA nchar(10)
 as
 begin
 
	Delete KHUYENMAI_CT_TIEC
	Where ID_SP=@ID_SP
      and MADV=@MADV
end

go

------------Menu_CT--------------------------


create proc sp_Menu_CT_Them
	@ID_Menu int
	,@MaTP int
as
begin
	insert into MENU_CT(ID_Menu
	,MaTP)
	values(@ID_Menu
	,@MaTP)
end

go

Create proc sp_Menu_CT_Xoa
	@ID_Menu int
	,@MaTP int
as
begin
	Delete MENU_CT
	where 
	ID_Menu=@ID_Menu
	and MaTP=@MaTP
end

go
-------------NHÀ HÀNG-----------------------

Create proc sp_NhaHang_Them
      @TENNH nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nvarchar(200)
      ,@SOBAN int
      ,@SOBANDATMIN nchar(10)
      ,@PHUTHU int
      ,@DATCOC1 int
      ,@DATCOC2 int
      ,@MAKS int
as
begin
 insert into NHAHANG(TENNH
      ,SODT
      ,DIACHI
      ,MANVQLY
      ,SOBAN
      ,SOBANDATMIN
      ,PHUTHU
      ,DATCOC1
      ,DATCOC2
      ,MAKS)values(
       @TENNH
      ,@SODT
      ,@DIACHI
      ,@MANVQLY
      ,@SOBAN
      ,@SOBANDATMIN
      ,@PHUTHU
      ,@DATCOC1
      ,@DATCOC2
      ,@MAKS
      )
	select @@IDENTITY
end

go

Create proc sp_NhaHang_Sua
      @TENNH nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nvarchar(200)
      ,@SOBAN int
      ,@SOBANDATMIN nchar(10)
      ,@PHUTHU int
      ,@DATCOC1 int
      ,@DATCOC2 int
      ,@MAKS int
      ,@MaNH int
as
begin
 update NHAHANG
 set TENNH=@TENNH
      ,SODT=@SODT
      ,DIACHI=@DIACHI
      ,MANVQLY=@MANVQLY
      ,SOBAN=@SOBAN
      ,SOBANDATMIN=@SOBANDATMIN
      ,PHUTHU=@PHUTHU
      ,DATCOC1=@DATCOC1
      ,DATCOC2=@DATCOC2
      ,MAKS=@MAKS
     where MANH=@MaNH
end

go

Create proc sp_NhaHang_Xoa
	@MaNH int
as
begin
	delete NHAHANG
    where MANH=@MaNH
end

go

-----------------------KHÁCH SẠN--------------------------------------
Create proc sp_KhachSan_Them
	   @MAKS int
      ,@TENKS nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nchar(10)
as
begin
	insert into KHACHSAN
	( 
	   MAKS
      ,TENKS
      ,SODT
      ,DIACHI
      ,MANVQLY
      )
      values(
	   @MAKS
      ,@TENKS
      ,@SODT
      ,@DIACHI
      ,@MANVQLY
      )
end

go

Create proc sp_KhachSan_Sua
	   @MAKS int
      ,@TENKS nvarchar(50)
      ,@SODT nvarchar(20)
      ,@DIACHI nvarchar(200)
      ,@MANVQLY nchar(10)
as
begin
	update KHACHSAN
	set
      TENKS=@TENKS
      ,SODT=@SODT
      ,DIACHI=@DIACHI
      ,MANVQLY=@MANVQLY
    where  MAKS=@MAKS
end

go

Create proc sp_KhachSan_Xoa
	   @MAKS int
as
begin
	delete KHACHSAN
    where  MAKS=@MAKS
end

go
------------------NHÀ HÀNG-PHÒNG----------------------


Create proc sp_NhaHang_Phong_Them
@SoPhong nchar(10)
,@MaNH int
,@Tang nchar(10)
as
begin
	insert into NHAHANG_PHONG
	(SOPHONG,MANH,TANG)values(@SoPhong,@MaNH,@Tang)
	select @@IDENTITY
end

go

Create proc sp_NhaHang_Phong_Sua
@SoPhong nchar(10)
,@MaNH int
,@Tang nchar(10)
,@ID_Phong int
as
begin
	update NHAHANG_PHONG
	set 
	SOPHONG=@SoPhong,MANH=@MaNH,TANG=@Tang
	where ID_PHONG=@ID_Phong 
end

go

Create proc sp_NhaHang_Phong_Xoa
@ID_Phong int
as
begin
	delete NHAHANG_PHONG
	where ID_PHONG=@ID_Phong 
end

go

-----------------NHÀ HÀNG - BAN----------------------

Create proc sp_NhaHang_Ban_Them
@ID_PHONG int,@SOBAN nchar(10),@SOCHO int
as
begin
	insert into NHAHANG_BAN
	(ID_PHONG,SOBAN,SOCHO)
	values(@ID_PHONG,@SOBAN,@SOCHO)
end

go


Create proc sp_NhaHang_Ban_Sua
@ID_PHONG int,@SOBAN nchar(10),@SOCHO int
as
begin
	update NHAHANG_BAN
	set SOCHO=@SOCHO
	where ID_PHONG=@ID_PHONG AND SOBAN=@SOBAN
end

go

Create proc sp_NhaHang_Ban_Xoa
@ID_PHONG int,@SOBAN nchar(10)
as
begin
	Delete NHAHANG_BAN
	where ID_PHONG=@ID_PHONG AND SOBAN=@SOBAN
end

go
-------------------------------------------------------------------------------------------------------
/*				CHECK IN				*/
-------------------------------------------------------------------------------------------------------


-----------------------DỊCH VỤ---------------

Create proc sp_DichVu_Them
	   @MADV nchar(10)
      ,@DIENGIAI nvarchar(100)
      ,@TYLETHUE int
      ,@TINHTHUE bit
      ,@PHIDICHVU int
      ,@TINHPHI bit
      ,@TYLETTDB int
      ,@TINHTTDB bit
      ,@MALOAIDV nchar(10)
      ,@GHICHU nvarchar(200)
as
begin
insert into DICHVU(MADV
      ,DIENGIAI
      ,TYLETHUE
      ,TINHTHUE
      ,PHIDICHVU
      ,TINHPHI
      ,TYLETTDB
      ,TINHTTDB
      ,MALOAIDV
      ,GHICHU)values(
       @MADV
      ,@DIENGIAI
      ,@TYLETHUE
      ,@TINHTHUE
      ,@PHIDICHVU
      ,@TINHPHI 
      ,@TYLETTDB
      ,@TINHTTDB
      ,@MALOAIDV
      ,@GHICHU 
      )
end

go

Create proc sp_DichVu_Sua
	   @MADV nchar(10)
      ,@DIENGIAI nvarchar(100)
      ,@TYLETHUE int
      ,@TINHTHUE bit
      ,@PHIDICHVU int
      ,@TINHPHI bit
      ,@TYLETTDB int
      ,@TINHTTDB bit
      ,@MALOAIDV nchar(10)
      ,@GHICHU nvarchar(200)
as
begin
	update DICHVU
	set 
	
      DIENGIAI=@DIENGIAI
      ,TYLETHUE=@TYLETHUE
      ,TINHTHUE=@TINHTHUE
      ,PHIDICHVU=@PHIDICHVU
      ,TINHPHI=@TINHPHI
      ,TYLETTDB=@TYLETTDB
      ,TINHTTDB=@TINHTTDB
      ,MALOAIDV=@MALOAIDV
      ,GHICHU=@GHICHU
    where 	MADV=@MADV
end

go

Create proc sp_DichVu_Them
	   @MADV nchar(10)
      ,@DIENGIAI nvarchar(100)
      ,@TYLETHUE int
      ,@TINHTHUE bit
      ,@PHIDICHVU int
      ,@TINHPHI bit
      ,@TYLETTDB int
      ,@TINHTTDB bit
      ,@MALOAIDV nchar(10)
      ,@GHICHU nvarchar(200)
as
begin
insert into DICHVU(MADV
      ,DIENGIAI
      ,TYLETHUE
      ,TINHTHUE
      ,PHIDICHVU
      ,TINHPHI
      ,TYLETTDB
      ,TINHTTDB
      ,MALOAIDV
      ,GHICHU)values(
       @MADV
      ,@DIENGIAI
      ,@TYLETHUE
      ,@TINHTHUE
      ,@PHIDICHVU
      ,@TINHPHI 
      ,@TYLETTDB
      ,@TINHTTDB
      ,@MALOAIDV
      ,@GHICHU 
      )
end

go

Create proc sp_DichVu_Xoa
	   @MADV nchar(10)
as
begin
	delete DICHVU
    where 	MADV=@MADV
end

go

--------------------PHIẾU THUÊ-------------------
create proc sp_PhieuThue_Them

		@SOPT nchar(20)
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@MABOOKING int
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTLIENHE nchar(20)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@TENDOAN nvarchar(200)
      ,@MANVLAP nchar(10)
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
      ,@GHICHU nvarchar(1000)
AS 
begin
set dateformat 'dmy'
	insert into PHIEUTHUE(	SOPT
      ,NGAYDEN
      ,GIODEN
      ,NGAYDI
      ,GIODI
      ,MABOOKING
      ,HOTENLIENHE
      ,SODTLIENHE
      ,SODTDDLIENHE
      ,ID_CTYLH
      ,ID_CTY
      ,TENDOAN
      ,MANVLAP
      ,MANV_UPDATE
      ,LASTUPDATE
      ,GHICHU)values
	(	@SOPT
      ,@NGAYDEN
      ,@GIODEN
      ,@NGAYDI
      ,@GIODI
      ,@MABOOKING
      ,@HOTENLIENHE
      ,@SODTLIENHE
      ,@SODTDDLIENHE
      ,@ID_CTYLH
      ,@ID_CTY
      ,@TENDOAN
      ,@MANVLAP
      ,@MANV_UPDATE
      ,@LASTUPDATE
      ,@GHICHU)
end

go

create proc sp_PhieuThue_Sua

		@SOPT nchar(20)
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@MABOOKING int
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTLIENHE nchar(20)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@TENDOAN nvarchar(200)
      ,@MANVLAP nchar(10)
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
      ,@GHICHU nvarchar(1000)
AS 
begin
set dateformat 'dmy'
	update PHIEUTHUE
	set	
      NGAYDEN=@NGAYDEN
      ,GIODEN=@GIODEN
      ,NGAYDI=@NGAYDI
      ,GIODI=@GIODI
      ,MABOOKING=@MABOOKING
      ,HOTENLIENHE=@HOTENLIENHE
      ,SODTLIENHE=@SODTLIENHE
      ,SODTDDLIENHE=@SODTDDLIENHE
      ,ID_CTYLH=@ID_CTYLH
      ,ID_CTY=@ID_CTY
      ,TENDOAN=@TENDOAN
      ,MANVLAP=@MANVLAP
      ,MANV_UPDATE=@MANV_UPDATE
      ,LASTUPDATE=@LASTUPDATE
      ,GHICHU=@GHICHU
   where   SOPT=@SOPT
end

go

create proc sp_PhieuThue_Sua
	@SOPT nchar(20)
AS 
begin
	delete PHIEUTHUE
   where   SOPT=@SOPT
end

go

--------------PHIẾU THUÊ VÃNG LAI----------------------

Create proc sp_PhieuThue_VangLai_Them
		@SOPT nchar(20)
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@HOAHONG int
      ,@MATT nchar(10)
      ,@SOTHE nchar(30)
      ,@DATCOC int
      ,@MAPLTT int
      ,@NGAYHETHAN datetime
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
      ,@GHICHU nvarchar(100)
as
begin
	set dateformat 'dmy'
insert into PHIEUTHUE_VANGLAI(
		SOPT 
      ,NGAYDEN 
      ,GIODEN 
      ,NGAYDI 
      ,GIODI 
      ,HOTENLIENHE 
      ,SODTDDLIENHE 
      ,ID_CTYLH 
      ,ID_CTY 
      ,HOAHONG 
      ,MATT 
      ,SOTHE 
      ,DATCOC 
      ,MAPLTT 
      ,NGAYHETHAN 
      ,MANV_UPDATE 
      ,LASTUPDATE 
      ,GHICHU 
  
	)values(
		@SOPT
      ,@NGAYDEN
      ,@GIODEN
      ,@NGAYDI
      ,@GIODI
      ,@HOTENLIENHE
      ,@SODTDDLIENHE
      ,@ID_CTYLH
      ,@ID_CTY
      ,@HOAHONG
      ,@MATT
      ,@SOTHE
      ,@DATCOC
      ,@MAPLTT
      ,@NGAYHETHAN
      ,@MANV_UPDATE
      ,@LASTUPDATE
      ,@GHICHU
      )
end

go

Create proc sp_PhieuThue_VangLai_Sua
		@SOPT nchar(20)
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@HOTENLIENHE nvarchar(100)
      ,@SODTDDLIENHE nchar(20)
      ,@ID_CTYLH int
      ,@ID_CTY int
      ,@HOAHONG int
      ,@MATT nchar(10)
      ,@SOTHE nchar(30)
      ,@DATCOC int
      ,@MAPLTT int
      ,@NGAYHETHAN datetime
      ,@MANV_UPDATE nchar(10)
      ,@LASTUPDATE datetime
      ,@GHICHU nvarchar(100)
as
begin
	set dateformat 'dmy'
	update PHIEUTHUE_VANGLAI
    set 
       NGAYDEN= @NGAYDEN
      ,GIODEN =@GIODEN
      ,NGAYDI =@NGAYDI
      ,GIODI =@GIODI
      ,HOTENLIENHE =@HOTENLIENHE
      ,SODTDDLIENHE =@SODTDDLIENHE
      ,ID_CTYLH =@ID_CTYLH
      ,ID_CTY =@ID_CTY
      ,HOAHONG =@HOAHONG
      ,MATT =@MATT
      ,SOTHE =@SOTHE
      ,DATCOC =@DATCOC
      ,MAPLTT =@MAPLTT
      ,NGAYHETHAN =@NGAYHETHAN
      ,MANV_UPDATE =@MANV_UPDATE
      ,LASTUPDATE =@LASTUPDATE
      ,GHICHU =@GHICHU
   WHERE SOPT =@SOPT
end

go

Create proc sp_PhieuThue_VangLai_Xoa
	@SOPT nchar(20)
as
begin
	delete PHIEUTHUE_VANGLAI
   WHERE SOPT =@SOPT
end

go

-----------------CHI TIẾT PHIẾU THUÊ---------------------------------

Create proc sp_CT_PHieuThue_Them

	   @SOPT nchar(20)
      ,@MAPH nchar(10)
      ,@ID_THUE int
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@GIAPHONG int
      ,@THEMGIUONG int
      ,@TRATHEM int
      ,@GIAMGIA int
      ,@DATHANHTOAN int
      ,@GHICHU nvarchar(200)
as
begin
	set dateformat 'dmy'
	insert into CT_PHIEUTHUE(
	  SOPT
      ,MAPH
      ,ID_THUE
      ,NGAYDEN
      ,GIODEN
      ,NGAYDI
      ,GIODI
      ,GIAPHONG
      ,THEMGIUONG
      ,TRATHEM
      ,GIAMGIA
      ,DATHANHTOAN
      ,GHICHU
	)values(
	   @SOPT
      ,@MAPH
      ,@ID_THUE
      ,@NGAYDEN
      ,@GIODEN
      ,@NGAYDI
      ,@GIODI
      ,@GIAPHONG
      ,@THEMGIUONG
      ,@TRATHEM
      ,@GIAMGIA
      ,@DATHANHTOAN
      ,@GHICHU
	)
end
go

Create proc sp_CT_PHieuThue_Sua

	   @SOPT nchar(20)
      ,@MAPH nchar(10)
      ,@ID_THUE int
      ,@NGAYDEN date
      ,@GIODEN time(7)
      ,@NGAYDI date
      ,@GIODI time(7)
      ,@GIAPHONG int
      ,@THEMGIUONG int
      ,@TRATHEM int
      ,@GIAMGIA int
      ,@DATHANHTOAN int
      ,@GHICHU nvarchar(200)
as
begin
	set dateformat 'dmy'
	update CT_PHIEUTHUE
	set
       MAPH=@MAPH
      ,ID_THUE=@ID_THUE
      ,NGAYDEN=@NGAYDEN
      ,GIODEN=@GIODEN
      ,NGAYDI=@NGAYDI
      ,GIODI=@GIODI
      ,GIAPHONG=@GIAPHONG
      ,THEMGIUONG=@THEMGIUONG
      ,TRATHEM=@TRATHEM
      ,GIAMGIA=@GIAMGIA
      ,DATHANHTOAN=@DATHANHTOAN
      ,GHICHU=@GHICHU
     where  SOPT=@SOPT
end
go

Create proc sp_CT_PHieuThue_Xoa

	   @SOPT nchar(20)
as
begin
	delete CT_PHIEUTHUE
     where  SOPT=@SOPT
end
go



-----------------------------CHI TIẾT PHÒNG - GIAT UI-----------------------

Create proc sp_CT_Phong_GiatUi_Them
	  @ID_THUE int
      ,@MAGUI int
      ,@SOLG int
      ,@GIAGIAT int
      ,@GIAUI int
      ,@GIAHAP int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin 
	set dateformat 'dmy'
	insert into CT_PHONG_GIATUI(ID_THUE
      ,MAGUI
      ,SOLG
      ,GIAGIAT
      ,GIAUI
      ,GIAHAP
      ,MANV
      ,NGAYGIO
      ,DATRA)values(  @ID_THUE
      ,@MAGUI
      ,@SOLG
      ,@GIAGIAT
      ,@GIAUI
      ,@GIAHAP
      ,@MANV
      ,@NGAYGIO
      ,@DATRA)
end

go

Create proc sp_CT_Phong_GiatUi_Sua
	  @ID_THUE int
      ,@MAGUI int
      ,@SOLG int
      ,@GIAGIAT int
      ,@GIAUI int
      ,@GIAHAP int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin 
	set dateformat 'dmy'
	update CT_PHONG_GIATUI
	set 
	 
      SOLG=@SOLG
      ,GIAGIAT=@GIAGIAT
      ,GIAUI=@GIAUI
      ,GIAHAP=@GIAHAP
      ,MANV=@MANV
      ,NGAYGIO=@NGAYGIO
      ,DATRA=@DATRA
    where   ID_THUE=@ID_THUE
      and MAGUI=@MAGUI
end

go

Create proc sp_CT_Phong_GiatUi_Xoa
	  @ID_THUE int
      ,@MAGUI int
as
begin 
	delete CT_PHONG_GIATUI
    where   ID_THUE=@ID_THUE
      and MAGUI=@MAGUI
end

go


---------------------------GIẶT ỦI-------------------------------------

create proc Sp_GiatUi_Them
	  
      @DIENGIAI nvarchar(100)
      ,@GIAGIAT int
      ,@GIAUI int
      ,@GIAHAP int
      ,@MANHOM int
as
begin
	insert into GIATUI( 
      DIENGIAI
      ,GIAGIAT
      ,GIAUI
      ,GIAHAP
      ,MANHOM)values( 
      @DIENGIAI
      ,@GIAGIAT
      ,@GIAUI
      ,@GIAHAP
      ,@MANHOM)
     select @@IDENTITY
end

go

Create proc Sp_GiatUi_Sua
	 
      @DIENGIAI nvarchar(100)
      ,@GIAGIAT int
      ,@GIAUI int
      ,@GIAHAP int
      ,@MANHOM int
      ,@MaGui int
as
begin
	update GIATUI
	set
	 
      DIENGIAI=@DIENGIAI
      ,GIAGIAT=@GIAGIAT
      ,GIAUI=@GIAUI
      ,GIAHAP=@GIAHAP
      ,MANHOM= @MANHOM
   where  MAGUI=@MAGUI
end

go

Create proc Sp_GiatUi_Xoa
      @MaGui int
as
begin
   delete GIATUI
   where  MAGUI=@MAGUI
end

go

------------------CT_PHONG_THUCPHAM-------------------------
Create proc sp_CT_Phong_ThucPham_Them
	   @ID_THUE int
      ,@MATP int
      ,@SOLG int
      ,@DONGIA int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
as
begin insert into CT_PHONG_THUCPHAM( ID_THUE
      ,MATP
      ,SOLG
      ,DONGIA
      ,MANV
      ,NGAYGIO)
      values
      (@ID_THUE
      ,@MATP
      ,@SOLG
      ,@DONGIA
      ,@MANV
      ,@NGAYGIO)
end

go

Create proc sp_CT_Phong_ThucPham_Sua
	   @ID_THUE int
      ,@MATP int
      ,@SOLG int
      ,@DONGIA int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
as
begin update CT_PHONG_THUCPHAM
	  set
	 
      SOLG=@SOLG
      ,DONGIA=@DONGIA
      ,MANV=@MANV
      ,NGAYGIO=@NGAYGIO
      where   ID_THUE=@ID_THUE
      and MATP=@MATP
     
end

go

Create proc sp_CT_Phong_ThucPham_Xoa
	   @ID_THUE int
      ,@MATP int
     
as
begin delete CT_PHONG_THUCPHAM
      where   ID_THUE=@ID_THUE
      and MATP=@MATP
     
end

go

--------------------GIẶT ỦI-NHÓM-----------
Create proc sp_GiacUi_Nhom_Them
	@MaNhom int
	,@DienGiai nvarchar(50)
as
begin
	insert into GIATUI_NHOM (MANHOM,DIENGIAI)values(@MaNhom,@DienGiai)
end

go

Create proc sp_GiacUi_Nhom_Sua
	@MaNhom int
	,@DienGiai nvarchar(50)
as
begin
	update GIATUI_NHOM set DIENGIAI=@DienGiai
	where @MaNhom=MANHOM
end

go

Create proc sp_GiacUi_Nhom_Xoa
	@MaNhom int
as
begin
	delete GIATUI_NHOM 
	where @MaNhom=MANHOM
end

go

-------------------THỰC PHẨM _MINIBAR--------------------
Create proc sp_ThucPham_MB_Them
      @TENMON nvarchar(50)
      ,@DVT nvarchar(15)
      ,@MALOAITP int
      ,@MANHOMTP int
as
begin
	insert into THUCPHAM_MB(
      TENMON
      ,DVT
      ,MALOAITP
      ,MANHOMTP)values( @TENMON
      ,@DVT
      ,@MALOAITP
      ,@MANHOMTP)
      select @@IDENTITY
end

go

Create proc sp_ThucPham_MB_Sua
      @TENMON nvarchar(50)
      ,@DVT nvarchar(15)
      ,@MALOAITP int
      ,@MANHOMTP int
      ,@MaMon int
as
begin
	update THUCPHAM_MB
	set
      TENMON=@TENMON
      ,DVT=@DVT
      ,MALOAITP=@MALOAITP
      ,MANHOMTP=@MANHOMTP
    where MAMON=@MaMon
end

go


Create proc sp_ThucPham_MB_Xoa
   @MaMon int
as
begin
	delete THUCPHAM_MB
    where MAMON=@MaMon
end

go

-----------------------CHI TIẾT PHÒNG-MINIBAR---------------

create proc sp_CT_Phong_Minibar_Them
      @ID_THUE int
      ,@MAMON int
      ,@SOLG int
      ,@DONGIA int
      ,@FREE bit
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin
	set dateformat 'dmy'
	insert into CT_PHONG_MINIBAR(   ID_THUE   ,MAMON
      ,SOLG
      ,DONGIA
      ,FREE
      ,MANV
      ,NGAYGIO
      ,DATRA)values(   @ID_THUE
      ,@MAMON
      ,@SOLG
      ,@DONGIA
      ,@FREE
      ,@MANV
      ,@NGAYGIO
      ,@DATRA)
end

go

create proc sp_CT_Phong_Minibar_Sua
      @ID_THUE int
      ,@MAMON int
      ,@SOLG int
      ,@DONGIA int
      ,@FREE bit
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin
	set dateformat 'dmy'
	update CT_PHONG_MINIBAR
	set   
	 
      SOLG=@SOLG
      ,DONGIA=@DONGIA
      ,FREE=@FREE
      ,MANV=@MANV
      ,NGAYGIO=@NGAYGIO
      ,DATRA=@DATRA
    where  ID_THUE =  @ID_THUE
	  and MAMON=@MAMON
end


go

create proc sp_CT_Phong_Minibar_Xoa
      @ID_THUE int
      ,@MAMON int
as
begin
	delete CT_PHONG_MINIBAR
    where  ID_THUE =  @ID_THUE
	  and MAMON=@MAMON
end

go

-------------------------PHÂN LOẠI THỊ TRƯỜNG --------------------------------

create proc sp_PhanLoaiThiTruong_Them
  @DIENGIAI nvarchar(50)
  ,@CANHAN bit
  ,@DOAN bit
  ,@VANGLAI bit
  ,@MIENPHI bit
as begin

	insert into PHANLOAITHITRUONG( ,DIENGIAI
  ,CANHAN
  ,DOAN
  ,VANGLAI
  ,IENPHI)values(@DIENGIAI
  ,@CANHAN
  ,@DOAN
  ,@VANGLAI
  ,@MIENPHI)
  select @@IDENTITY
end

go

create proc sp_PhanLoaiThiTruong_Sua
  @DIENGIAI nvarchar(50)
  ,@CANHAN bit
  ,@DOAN bit
  ,@VANGLAI bit
  ,@MIENPHI bit
  ,@MaPLTT int
as begin

  update PHANLOAITHITRUONG
  set DIENGIAI=@DIENGIAI
  ,CANHAN=@CANHAN
  ,DOAN=@DOAN
  ,VANGLAI=@VANGLAI
  ,MIENPHI=@MIENPHI
  where MaPLTT=@MaPLTT
end

go

create proc sp_PhanLoaiThiTruong_Xoa

  @MaPLTT int
as begin

  delete PHANLOAITHITRUONG
  where MaPLTT=@MaPLTT
end

go


------------------------CT_PHONG_DICHVU----------------------------

CREATE proc sp_CT_Phong_DichVu_Them

	   @ID_THUE int
      ,@MADV nchar(10)
      ,@SOLG  int
      ,@DONGIA int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin
	insert into CT_PHONG_DICHVU(
	   ID_THUE
      ,MADV
      ,SOLG
      ,DONGIA
      ,MANV
      ,NGAYGIO
      ,DATRA)values(
         @ID_THUE
      ,@MADV
      ,@SOLG
      ,@DONGIA
      ,@MANV
      ,@NGAYGIO
      ,@DATRA
      )
end

go

CREATE proc sp_CT_Phong_DichVu_Sua

	   @ID_THUE int
      ,@MADV nchar(10)
      ,@SOLG  int
      ,@DONGIA int
      ,@MANV nchar(10)
      ,@NGAYGIO datetime
      ,@DATRA bit
as
begin
	update CT_PHONG_DICHVU
	set
	  
      SOLG=@SOLG
      ,DONGIA=@DONGIA
      ,MANV=@MANV
      ,NGAYGIO=@NGAYGIO
      ,DATRA=@DATRA
     where 
      ID_THUE=@ID_THUE
      and MADV=@MADV
end


go

CREATE proc sp_CT_Phong_DichVu_Xoa
	   @ID_THUE int
      ,@MADV nchar(10)
      
as
begin
	delete CT_PHONG_DICHVU
	where 
	ID_THUE=@ID_THUE and MADV=@MADV
end

go
---------------------KHÁCH THUE------------------------------

Create proc sp_KhachThue_Them


      @SOCMND_PASSPORT nvarchar(20)
      ,@NOICAP nchar(3)
      ,@NGAYCAP date
      ,@DANHXUNG nchar(5)
      ,@HO nvarchar(80)
      ,@TEN nvarchar(20)
      ,@NGAYSINH date
      ,@PHAI nchar(3)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20) 
      ,@EMAIL nvarchar(100)
      ,@FAX nvarchar(20)
      ,@MANN int
      ,@MAQG nchar(10)
      ,@SOTHITHUC nvarchar(50)
      ,@LYDONHAPCANH nvarchar(100)
      ,@MAPLTT int
      ,@MALK nchar(2)
      ,@MANK int
      ,@GHICHU nvarchar(100)
      ,@MAGG nchar(2)
as
begin
	insert into KHACHTHUE(SOCMND_PASSPORT
      ,NOICAP
      ,NGAYCAP
      ,DANHXUNG
      ,HO
      ,TEN
      ,NGAYSINH
      ,PHAI
      ,DIACHI
      ,SODT
      ,EMAIL
      ,FAX
      ,MANN
      ,MAQG
      ,SOTHITHUC
      ,LYDONHAPCANH
      ,MAPLTT
      ,MALK
      ,MANK
      ,GHICHU
      ,MAGG)values(
      @SOCMND_PASSPORT
      ,@NOICAP
      ,@NGAYCAP
      ,@DANHXUNG
      ,@HO
      ,@TEN
      ,@NGAYSINH
      ,@PHAI
      ,@DIACHI
      ,@SODT
      ,@EMAIL
      ,@FAX
      ,@MANN
      ,@MAQG
      ,@SOTHITHUC
      ,@LYDONHAPCANH
      ,@MAPLTT
      ,@MALK
      ,@MANK
      ,@GHICHU
      ,@MAGG
      )
	select @@IDENTITY
end

go

Create proc sp_KhachThue_Sua
      @SOCMND_PASSPORT nvarchar(20)
      ,@NOICAP nchar(3)
      ,@NGAYCAP date
      ,@DANHXUNG nchar(5)
      ,@HO nvarchar(80)
      ,@TEN nvarchar(20)
      ,@NGAYSINH date
      ,@PHAI nchar(3)
      ,@DIACHI nvarchar(200)
      ,@SODT nvarchar(20) 
      ,@EMAIL nvarchar(100)
      ,@FAX nvarchar(20)
      ,@MANN int
      ,@MAQG nchar(10)
      ,@SOTHITHUC nvarchar(50)
      ,@LYDONHAPCANH nvarchar(100)
      ,@MAPLTT int
      ,@MALK nchar(2)
      ,@MANK int
      ,@GHICHU nvarchar(100)
      ,@MAGG nchar(2)
      ,@ID_KHACHTHUE int
as
begin
	update KHACHTHUE
	set 
	SOCMND_PASSPORT=@SOCMND_PASSPORT
      ,NOICAP=@NOICAP
      ,NGAYCAP=@NGAYCAP
      ,DANHXUNG=@DANHXUNG
      ,HO=@HO
      ,TEN=@TEN
      ,NGAYSINH=@NGAYSINH
      ,PHAI=@PHAI
      ,DIACHI=@DIACHI
      ,SODT=@SODT
      ,EMAIL=@EMAIL
      ,FAX=@FAX
      ,MANN=@MANN
      ,MAQG=@MAQG
      ,SOTHITHUC=@SOTHITHUC
      ,LYDONHAPCANH=@LYDONHAPCANH
      ,MAPLTT=@MAPLTT
      ,MALK=@MALK
      ,MANK=@MANK
      ,GHICHU=@GHICHU
      ,MAGG=@MAGG
	where ID_KHACHTHUE=@ID_KHACHTHUE
end


go


Create proc sp_KhachThue_Xoa
      @ID_KHACHTHUE int
as
begin
	delete KHACHTHUE
	where ID_KHACHTHUE=@ID_KHACHTHUE
end

go
 
Create proc sp_CT_Phong_Khach_Them
@ID_Thue int
,@ID_KhachThue int
as
begin
	insert into CT_PHONG_KHACH
	(ID_THUE,ID_KHACHTHUE)
	values(@ID_Thue,@ID_KhachThue)
end

go

Create proc sp_CT_Phong_Khach_Xoa
@ID_Thue int
,@ID_KhachThue int
as
begin
	delete CT_PHONG_KHACH
	where ID_THUE=@ID_Thue and ID_KHACHTHUE=@ID_KhachThue
end

go
-------------------------------MINIBAR--------------------------------

Create  proc sp_ThucPham_MB_Them
      @TENMON nvarchar(50)
      ,@DVT nvarchar(15)
      ,@MALOAITP int
      ,@MANHOMTP int
as
begin
	insert into THUCPHAM_MB( 
      TENMON
      ,DVT
      ,MALOAITP
      ,MANHOMTP)
      values(
	  @TENMON
      ,@DVT
      ,@MALOAITP
      ,@MANHOMTP
      )
      
end

go

Create  proc sp_ThucPham_MB_Sua
      @TENMON nvarchar(50)
      ,@DVT nvarchar(15)
      ,@MALOAITP int
      ,@MANHOMTP int
      ,@MaMon int
as
begin
	update THUCPHAM_MB
    set
      TENMON=@TENMON
      ,DVT=@DVT
      ,MALOAITP=@MALOAITP
      ,MANHOMTP=@MANHOMTP
    where MAMON=@MaMon
end

go

Create  proc sp_ThucPham_MB_Sua
      @MaMon int
as
begin
	delete THUCPHAM_MB
    where MAMON=@MaMon
end

go
-----------------THỰC PHẨM - NHỐM------------------------
create proc sp_ThucPham_Nhom_Them
@DienGiai nvarchar(30)
as
begin
	insert into THUCPHAM_NHOM(DIENGIAI)values(@DienGiai)
	select @@IDENTITY
end

GO

create proc sp_ThucPham_Nhom_Sua
@DienGiai nvarchar(30)
,@MANHOMTP int
as
begin
	update THUCPHAM_NHOM
	set DIENGIAI=@DienGiai
	where MANHOMTP=@MANHOMTP
end

go

create proc sp_ThucPham_Nhom_Xoa
@MANHOMTP int
as
begin
	delete THUCPHAM_NHOM
	where MANHOMTP=@MANHOMTP
end

go

-------------------------------THỰC PHÂM_MB_GIA----------
Create proc sp_ThucPham_MB_Gia_Them
@MaMon int
,@Ngay date
,@Gia int
as
begin
	set dateformat 'dmy'
	insert into THUCPHAM_MB_GIA(MAMON,NGAY,GIA)values(@MaMon,@Ngay,@Gia)
	select @@IDENTITY
end

GO

Create proc sp_ThucPham_MB_Gia_Sua
@MaMon int
,@Ngay date
,@Gia int
as
begin
	set dateformat 'dmy'
	update THUCPHAM_MB_GIA
	set GIA=@Gia
	where MAMON=@MaMon and NGAY=@Ngay
end

go

Create proc sp_ThucPham_MB_Gia_Xoa
@MaMon int
,@Ngay date
as
begin
	delete THUCPHAM_MB_GIA
	where MAMON=@MaMon and NGAY=@Ngay
end

go

--------------------------------------------------------------------
/*				THỰC PHẨM						*/
---------------------------------------------------------------------

Create proc sp_ThucPham_Loai_Them
@TenLoaiTP nvarchar(30)
as
begin
	
	insert into THUCPHAM_LOAI(TENLOAITP)values(@TenLoaiTP)
	select @@IDENTITY
end

go

Create proc sp_ThucPham_Loai_Sua
@MaLoaiTP int
,@TenLoaiTP nvarchar(30)
as
begin
	
	update THUCPHAM_LOAI
	set TENLOAITP=@TenLoaiTP
	where MALOAITP=@MaLoaiTP
end

go

Create proc sp_ThucPham_Loai_Xoa
 @MaLoaiTP int
as
begin
	
	delete THUCPHAM_LOAI
	where MALOAITP=@MaLoaiTP
end

go
